package com.zhu.salesmanagement.overlays;

import java.util.ArrayList;
import java.util.List;

import com.baidu.mapapi.GeoPoint;
import com.baidu.mapapi.ItemizedOverlay;
import com.baidu.mapapi.MapView;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;


public class StadiumOverlay extends ItemizedOverlay<StadiumOverlayItem> {
	private List<StadiumOverlayItem> items = new ArrayList<StadiumOverlayItem>(); 
    private Drawable marker = null; 
	private Context context ;
    public StadiumOverlay(Drawable defaultMaker ,Context ctx , List<StadiumOverlayItem> items) {
    	super(defaultMaker);
    	this.marker = defaultMaker ;
		if (items != null) {
			this.items = items ;
			initOverlayItems() ;
		} 
		this.context = ctx ;
	}
	

    public void addOverlay(StadiumOverlayItem overlay) { 
        items.add(overlay); 
        populate(); 
    } 

    protected boolean isRouteDisplayed() { 
        return false; 
    } 

    @Override 
    protected StadiumOverlayItem createItem(int i) { 
        return items.get(i); 
    } 

    @Override 
    public int size() { 
        return items.size(); 
    } 

    @Override
    public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
    		long when) {
    	super.draw(canvas, mapView, shadow, when);
    	boundCenterBottom(marker); 
    	return true ;
    }
    
    private void initOverlayItems() {
    	if (this.items != null) {
    		for (StadiumOverlayItem item : items) {
    			if (item != null) {
    				this.addOverlay(item);
    			}
    		}
		}
    	
    }
    
    @Override
    public boolean onTap(GeoPoint p, MapView mapView) {
    	return super.onTap(p, mapView);
    }
   
}
